<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/23
 * Time: 10:34
 */

namespace app\admin\controller;

use cmf\controller\AdminBaseController;
use think\Validate;
use think\Request;
use think\Db;
class InfoController extends AdminBaseController
{
    /**
     * 公司信息配置
     * @adminMenu(
     *     'name'   => '公司信息配置',
     *     'parent' => 'admin/Setting/default',
     *     'display'=> true,
     *     'hasView'=> true,
     *     'order'  => 10,
     *     'icon'   => '',
     *     'remark' => '公司信息配置',
     *     'param'  => ''
     * )
     */
    public function index()
    {

        return $this->fetch();
    }

    /**
     * 公司信息配置
     * @adminMenu(
     *     'name'   => '公司信息配置提交保存',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> false,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '公司信息配置提交保存',
     *     'param'  => ''
     * )
     */
    public function indexPost(Request $request)
    {
        $params = $request->param();
        if($params){
            $data = [
                'name1' => $params['name1'],
                'name2' => $params['name2'],
                'mobile1' => $params['mobile1'],
                'mobile2' => $params['mobile2'],
                'card1' => $params['card1'],
                'card2' => $params['card2'],
                'email' => $params['email'],
                'web' => $params['web'],
                'address'=>$params['address']
            ];

            $res = Db::name('infos')->where('id',1)->setField($data);

            if($res){
                $this->success('提交成功');
            }else{
                $this->error('提交失败');
            }
        }


        $this->success("保存成功！");
    }



}